package com.whminwei.edu.api.dc.dto.fspn.student;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhangjq
 * @since 2024-10-19
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DcScholarshipFspn {

    private List<DcScholarship> scholarships;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class DcScholarship implements Cloneable {
        /**
         * 项目ID
         */
        private String projectId;
        /**
         * 项目名称
         */
        private String projectName;
        /**
         * 项目种类
         */
        private String projectType;
        /**
         * 资助单位级别
         */
        private String unitLevel;
        /**
         * 资助单位名称
         */
        private String unitName;
        /**
         * 经费来源
         */
        private String sources;
        /**
         * 奖助标准
         */
        private String requirement;
        /**
         * 项目状态
         */
        private String status;
        /**
         * 奖助学生记录
         */
        private List<DcScholarStu> scholarStuList;
        /**
         * 删除标识
         */
        private String deleted;

        @Override
        public DcScholarship clone() {
            try {
                DcScholarship clone = (DcScholarship) super.clone();
                clone.setProjectId(this.projectId);
                clone.setProjectName(this.projectName);
                clone.setProjectType(this.projectType);
                clone.setUnitLevel(this.unitLevel);
                clone.setUnitName(this.unitName);
                clone.setSources(this.sources);
                clone.setRequirement(this.requirement);
                clone.setStatus(this.status);
                if (!CollectionUtils.isEmpty(this.scholarStuList)) {
                    clone.setScholarStuList(this.scholarStuList.stream().map(DcScholarStu::clone)
                            .collect(Collectors.toList()));
                }
                clone.setDeleted(this.deleted);
                return clone;
            } catch (CloneNotSupportedException e) {
                throw new AssertionError();
            }
        }
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class DcScholarStu implements Cloneable {
        /**
         * 记录ID
         */
        private String recordId;
        /**
         * 学生ID
         */
        private String studentId;
        /**
         * 金额
         */
        private Integer amount;
        /**
         * 申请时间
         */
        private String applicationTime;
        /**
         * 审批时间
         */
        private String approvalTime;
        /**
         * 审批人
         */
        private String approvalPerson;
        /**
         * 发放时间
         */
        private String grantTime;
        /**
         * 状态(待审核、未通过、待发放、已发放)
         */
        private String status;
        /**
         * 备注
         */
        private String remark;
        /**
         * 删除标识
         */
        private String deleted;

        @Override
        public DcScholarStu clone() {
            try {
                DcScholarStu clone = (DcScholarStu) super.clone();
                clone.setRecordId(this.recordId);
                clone.setStudentId(this.studentId);
                clone.setAmount(this.amount);
                clone.setApplicationTime(this.applicationTime);
                clone.setApprovalTime(this.approvalTime);
                clone.setApprovalPerson(this.approvalPerson);
                clone.setGrantTime(this.grantTime);
                clone.setStatus(this.status);
                clone.setRemark(this.remark);
                clone.setDeleted(this.deleted);
                return clone;
            } catch (CloneNotSupportedException e) {
                throw new AssertionError();
            }
        }
    }
}
